package com.tvein.sanguo.chat.view
{
	//flash
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	//pureMVC
	import org.puremvc.as3.multicore.interfaces.INotification;
	import org.puremvc.as3.multicore.utilities.fabrication.patterns.mediator.FlashMediator;
	//custom
	import com.tvein.sanguo.chat.common.GameConstants;
	import com.tvein.sanguo.chat.model.SystemProxy;
	import com.tvein.sanguo.Chat;
	import com.tvein.sanguo.swc.chat.ChatShell;
//
	public class ChatMediator extends FlashMediator
	{
		static public const NAME : String = "ChatMediator";
		
		public function ChatMediator(viewComponent:Object)
		{
			super(NAME, viewComponent);
		}
		
		public function get chat() : Chat
		{
			return viewComponent as Chat;
		}
		
		//Custom
		private var systemData:SystemProxy;
		public var chatShell:ChatShell;
		
		override public function onRegister() : void
		{			
			systemData = facade.retrieveProxy(SystemProxy.NAME) as SystemProxy;
			
			chat.visible = false;
			
			chatShell = new ChatShell();
			
			chat.addChild(chatShell);
			
			var params:Object = new Object();
			params.Volume = systemData.effectVol;
			chatShell.console("setEffect", params);
			
			chatShell.addEventListener("ChatShell", _handleEvents);
		}
		
		private function _handleEvents(evt:Object):void
		{
			routeNotification(GameConstants.GAME_CONSOLE, ["-gameCommand", evt.cmd[0]], null, "*");
		}
	}
}